<?
//引入所有子系统信息
include_once("../../../common/script/extender_import.php");


//**获取当前板块资料，必然载入，后续很多读取板块数据库的表格，都写成动态的了。
include_once("script/this_plate.php");

//**获取板块的设置，必然载入
include_once("../model/setting.php");


//根据筛选框传递过来的内容，组装查找语句
include_once("script/set_condition.php");


//根据页面信息，组装查找语句
include_once("script/set_page.php");


//根据页面数量信息，筛选信息，创造url，供页码使用
include_once("script/set_url.php");
include_once("script/set_order.php");



//获取数据。注意带上翻页，搜索，排序等数据
//$data_list_page=select_lines_all_items($table_prefix.$this_plate['table']['data'],$sort,$_condition,"$_data_start,$_quantity_per_page");

$data_list_page=select($table_prefix.$this_plate['table']['data'],
                        ['where'=>$_condition,
                         'limit'=>"$_data_start,$_quantity_per_page",
                         'order'=>$sort
                        ]);


//获取分类树
//按结构输出分类树
$category=select_lines_all_items($table_prefix.$this_plate['table']['category'],$sort,
    "parent_nid = 'root' and (delete_status != '已删除' or delete_status is null)","");


//循环，查找数据库中，parent_nid = 当前的 nid的值
foreach($category as $key=>$value)
{
    $category[$key]['level2']=select_lines_all_items($table_prefix.$this_plate['table']['category'],$sort,
        "parent_nid = '{$value['nid']}' and (delete_status != '已删除' or delete_status is null) ","");

    // 确保 level2_data 是数组
    if (is_array($category[$key]['level2']))
    {
        //开始循环第三级
        foreach($category[$key]['level2'] as $k=>$v)
        {
            $category[$key]['level2'][$k]['level3']=select_lines_all_items($table_prefix.$this_plate['table']['category'],
                $sort,"parent_nid = '{$v['nid']}' and (delete_status != '已删除' or delete_status is null) ","");
        }
    }

}



?>

